package b3.widget.vip
{
	import b3.net.*;
	import b3.widget.*;
	import b3.widget.basic.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.geom.Point;
	import flash.ui.Mouse;

	public class VipIcon extends Sprite
	{
		public function VipIcon(yellow_vip_level:int, is_yellow_year_vip:Boolean)
		{
			super();
			var VipIconImg:Class = ResourceHelper.getInstance().getClassByName("VipIcon" + yellow_vip_level + (is_yellow_year_vip ? "Year" : ""));
			addChild(new VipIconImg());
			this.mouseChildren = false;
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		private function onMouseClick(event:MouseEvent):void
		{
			var vipPrivilegesDialog:VipPrivilegesDialog = new VipPrivilegesDialog();
			WidgetManager.getInstance().popOut([vipPrivilegesDialog], true);
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
//			Mouse.cursor = "button";
			var globalPoint:Point = this.parent.localToGlobal(new Point(this.x, this.y));
			var tip:BasicMessage = new BasicMessage("查看黄钻特权");
			tip.x = globalPoint.x + this.width + 5;
			tip.y = globalPoint.y;
			WidgetManager.getInstance().popOutMouseOverMessage(tip);
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
//			Mouse.cursor = "auto";
			WidgetManager.getInstance().closeMouseOverMessage();
		}
	}
}